package com.xcity.game.combat.skill.impl;

import java.util.List;

import com.xcity.game.combat.Action;
import com.xcity.game.combat.ActionEffect;
import com.xcity.game.combat.attr.CombatAttributeType;
import com.xcity.game.combat.skill.CombatSkill;
import com.xcity.game.combat.unit.CombatUnit;
import com.xcity.game.common.GameStaticConfig;
import com.xcity.game.skill.Skill;

/**
 * 天花乱坠<br/>
 * 恢复我方全体{0=20#0}%气势
 * @author yang.li
 *
 */
public class COMBAT_SKILL_90087 extends CombatSkill {

	public COMBAT_SKILL_90087(Skill skill) {
		super(skill);
	}

	@Override
	public void calcDamage(Action action) {
		CombatUnit source = action.unit;
		List<CombatUnit> units = source.getTeam().all();
		float rate = skill.getParameter(0) / GameStaticConfig.percentBase;
		for (int i = 0; i < units.size(); i++) {
			CombatUnit unit = units.get(i);
			if (!unit.isDied()) {
				ActionEffect effect = action.addTarget(unit);
				unit = effect.getUnit(); // 修正目标
				int val = (int) (unit.getMaxHp() * rate);
				val = Math.max(val, 1);
				effect.effect(CombatAttributeType.HP, val);
			}
		}
	}

}
